package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
	"github.com/satori/go.uuid"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
	_ = uuid.UUID{}
)

/*
DB Table Details
-------------------------------------


CREATE TABLE `id_card` (
  `type` tinyint(2) unsigned zerofill NOT NULL COMMENT '类型',
  `id` bigint(20) unsigned zerofill NOT NULL COMMENT '对应表的id',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `id1` varchar(8) DEFAULT NULL,
  `id2` varchar(8) DEFAULT NULL,
  `id3` varchar(8) DEFAULT NULL,
  `id4` varchar(8) DEFAULT NULL,
  `id5` varchar(8) DEFAULT NULL,
  `id6` varchar(8) DEFAULT NULL,
  `id7` varchar(8) DEFAULT NULL,
  `id8` varchar(8) DEFAULT NULL,
  PRIMARY KEY (`id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='身份证号'

JSON Sample
-------------------------------------
{    "type": 89,    "id": 53,    "id_1": "FFdGjQJLVdWcWXqCSKOwDWDdJ",    "id_5": "KfVXfLfbmcEgpTscAuoLaUGuh",    "id_6": "fyLJfgDfDbvZLnqEhGuaFqDdl",    "id_7": "bSOGCkHyCfMLMGuxVNIglCdED",    "create_time": "2075-05-13T21:29:03.161760643+08:00",    "update_time": "2260-04-11T02:35:19.322715944+08:00",    "id_2": "mPDHFjHuTsfXPQBIeNJqhPhoI",    "id_3": "rVXkSXBomDLIghbaxaTAGHMpS",    "id_4": "TICVEKetDAEpvEOgTEOEVxUGm",    "id_8": "PwkrbCntpShTEmhfgWVpxaDcq"}


Comments
-------------------------------------
[ 0] column is set for unsigned
[ 1] column is set for unsigned



*/

// IDCard struct is a row record of the id_card table in the custom_process database
type IDCard struct {
	//[ 0] type                                           utinyint             null: false  primary: true   isArray: false  auto: false  col: utinyint        len: -1      default: []
	Type uint32 `gorm:"primary_key;column:type;type:utinyint;" json:"type"` // 类型
	//[ 1] id                                             ubigint              null: false  primary: true   isArray: false  auto: false  col: ubigint         len: -1      default: []
	ID uint64 `gorm:"primary_key;column:id;type:ubigint;" json:"id"` // 对应表的id
	//[ 2] create_time                                    datetime             null: true   primary: false  isArray: false  auto: false  col: datetime        len: -1      default: [NULL]
	CreateTime time.Time `gorm:"column:create_time;type:datetime;" json:"create_time"`
	//[ 3] update_time                                    datetime             null: true   primary: false  isArray: false  auto: false  col: datetime        len: -1      default: [NULL]
	UpdateTime time.Time `gorm:"column:update_time;type:datetime;" json:"update_time"`
	//[ 4] id1                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID1 sql.NullString `gorm:"column:id1;type:varchar;size:8;" json:"id_1"`
	//[ 5] id2                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID2 sql.NullString `gorm:"column:id2;type:varchar;size:8;" json:"id_2"`
	//[ 6] id3                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID3 sql.NullString `gorm:"column:id3;type:varchar;size:8;" json:"id_3"`
	//[ 7] id4                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID4 sql.NullString `gorm:"column:id4;type:varchar;size:8;" json:"id_4"`
	//[ 8] id5                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID5 sql.NullString `gorm:"column:id5;type:varchar;size:8;" json:"id_5"`
	//[ 9] id6                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID6 sql.NullString `gorm:"column:id6;type:varchar;size:8;" json:"id_6"`
	//[10] id7                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID7 sql.NullString `gorm:"column:id7;type:varchar;size:8;" json:"id_7"`
	//[11] id8                                            varchar(8)           null: true   primary: false  isArray: false  auto: false  col: varchar         len: 8       default: [NULL]
	ID8 sql.NullString `gorm:"column:id8;type:varchar;size:8;" json:"id_8"`
}

var id_cardTableInfo = &TableInfo{
	Name: "id_card",
	Columns: []*ColumnInfo{

		{
			Index:              0,
			Name:               "type",
			Comment:            `类型`,
			Notes:              `column is set for unsigned`,
			Nullable:           false,
			DatabaseTypeName:   "utinyint",
			DatabaseTypePretty: "utinyint",
			IsPrimaryKey:       true,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "utinyint",
			ColumnLength:       -1,
			GoFieldName:        "Type",
			GoFieldType:        "uint32",
			JSONFieldName:      "type",
			ProtobufFieldName:  "type",
			ProtobufType:       "uint32",
			ProtobufPos:        1,
		},

		{
			Index:              1,
			Name:               "id",
			Comment:            `对应表的id`,
			Notes:              `column is set for unsigned`,
			Nullable:           false,
			DatabaseTypeName:   "ubigint",
			DatabaseTypePretty: "ubigint",
			IsPrimaryKey:       true,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "ubigint",
			ColumnLength:       -1,
			GoFieldName:        "ID",
			GoFieldType:        "uint64",
			JSONFieldName:      "id",
			ProtobufFieldName:  "id",
			ProtobufType:       "uint64",
			ProtobufPos:        2,
		},

		{
			Index:              2,
			Name:               "create_time",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "datetime",
			DatabaseTypePretty: "datetime",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "datetime",
			ColumnLength:       -1,
			GoFieldName:        "CreateTime",
			GoFieldType:        "time.Time",
			JSONFieldName:      "create_time",
			ProtobufFieldName:  "create_time",
			ProtobufType:       "google.protobuf.Timestamp",
			ProtobufPos:        3,
		},

		{
			Index:              3,
			Name:               "update_time",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "datetime",
			DatabaseTypePretty: "datetime",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "datetime",
			ColumnLength:       -1,
			GoFieldName:        "UpdateTime",
			GoFieldType:        "time.Time",
			JSONFieldName:      "update_time",
			ProtobufFieldName:  "update_time",
			ProtobufType:       "google.protobuf.Timestamp",
			ProtobufPos:        4,
		},

		{
			Index:              4,
			Name:               "id1",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID1",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_1",
			ProtobufFieldName:  "id_1",
			ProtobufType:       "string",
			ProtobufPos:        5,
		},

		{
			Index:              5,
			Name:               "id2",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID2",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_2",
			ProtobufFieldName:  "id_2",
			ProtobufType:       "string",
			ProtobufPos:        6,
		},

		{
			Index:              6,
			Name:               "id3",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID3",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_3",
			ProtobufFieldName:  "id_3",
			ProtobufType:       "string",
			ProtobufPos:        7,
		},

		{
			Index:              7,
			Name:               "id4",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID4",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_4",
			ProtobufFieldName:  "id_4",
			ProtobufType:       "string",
			ProtobufPos:        8,
		},

		{
			Index:              8,
			Name:               "id5",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID5",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_5",
			ProtobufFieldName:  "id_5",
			ProtobufType:       "string",
			ProtobufPos:        9,
		},

		{
			Index:              9,
			Name:               "id6",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID6",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_6",
			ProtobufFieldName:  "id_6",
			ProtobufType:       "string",
			ProtobufPos:        10,
		},

		{
			Index:              10,
			Name:               "id7",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID7",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_7",
			ProtobufFieldName:  "id_7",
			ProtobufType:       "string",
			ProtobufPos:        11,
		},

		{
			Index:              11,
			Name:               "id8",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "varchar",
			DatabaseTypePretty: "varchar(8)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "varchar",
			ColumnLength:       8,
			GoFieldName:        "ID8",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "id_8",
			ProtobufFieldName:  "id_8",
			ProtobufType:       "string",
			ProtobufPos:        12,
		},
	},
}

// TableName sets the insert table name for this struct type
func (i *IDCard) TableName() string {
	return "id_card"
}

// BeforeSave invoked before saving, return an error if field is not populated.
func (i *IDCard) BeforeSave() error {
	return nil
}

// Prepare invoked before saving, can be used to populate fields etc.
func (i *IDCard) Prepare() {
}

// Validate invoked before performing action, return an error if field is not populated.
func (i *IDCard) Validate(action Action) error {
	return nil
}

// TableInfo return table meta data
func (i *IDCard) TableInfo() *TableInfo {
	return id_cardTableInfo
}
